package com.and.dialog;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;

import androidx.collection.ArrayMap;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;


import com.htg.dialog.AndroidDialog;
import com.htg.dialog.DialogAMapDownloading;
import com.htg.dialog.DialogDonotKnowPosition;
import com.htg.dialog.DialogInput;
import com.htg.dialog.DialogKeyValueInput;
import com.htg.dialog.DialogPandu;
import com.htg.dialog.DialogStandardTwoButton;
import com.htg.dialog.DialogYunChaxun;

import java.util.Arrays;
import java.util.List;

public class MainActivity extends Activity implements ExampleAdapter.OnItemClickListener {

    private RecyclerView recyclerView;

    private AndroidDialog androidDialog;

    private List<String> stringList = Arrays.asList("DialogAgreementHint.java", "DialogAMapDownloading.java", "DialogDonotKnowPosition.java"
            , "DialogError.java", "DialogHint.java", "DialogInput.java", "DialogKeyValueInput.java", "DialogKeyValueTable.java", "DialogLoveHint.java",
            "DialogNewVersionHint.java", "DialogPandu.java", "DialogRealNameAuthAndTaxDeclaration.java", "DialogStandardOneButton.java",
            "DialogStandardTwoButton.java", "DialogTaskCompleteState.java", "DialogTextItems.java", "DialogWaitting.java",
            "DialogWarn.java", "DialogYunChaxun.java");

    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        recyclerView = findViewById(R.id.recyclerview);

        ExampleAdapter exampleAdapter = new ExampleAdapter(this, stringList);
        exampleAdapter.setOnItemClickListener(this);
        recyclerView.setAdapter(exampleAdapter);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));

        androidDialog = new AndroidDialog(this);
        androidDialog.setColorPrimary(getResources().getColor(R.color.colorPrimary, getTheme()));
        androidDialog.setCornerRadius(getResources().getDimensionPixelSize(R.dimen.dp_5));
    }

    @Override
    public void onItemClick(int index, String name) {
        switch (name) {
            case "DialogAgreementHint.java":
                androidDialog.showAgreementHint(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                }, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                }, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                }, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                });
                break;
            case "DialogAMapDownloading.java":
                androidDialog.showDialogAMapDownloading(new DialogAMapDownloading.OnClickListener() {
                    @Override
                    public void onClick(AlertDialog alertDialog) {
                        alertDialog.dismiss();
                    }
                });
                break;
            case "DialogDonotKnowPosition.java":
                androidDialog.showDialogDonotKnowPosition(new DialogDonotKnowPosition.OnDialogDonnotKnowPositionOperationListener() {
                    @Override
                    public void onDialogDonnotKnowPositionClose(boolean donothint) {

                    }

                    @Override
                    public void onDialogDonnotKnowPositionChoose(boolean donothint) {

                    }

                    @Override
                    public void onDialogDonnotKnowPositionLocate(boolean donothint) {

                    }
                });
                break;
            case "DialogError.java":
                androidDialog.error("错误信息");
                break;
            case "DialogHint.java":
                androidDialog.hint("提示信息");
                break;
            case "DialogInput.java":
                androidDialog.showInput("内容", "左边", "右边", new DialogInput.OnDialogInputClickListener() {
                    @Override
                    public void onClick(String input) {

                    }
                }, new DialogInput.OnDialogInputClickListener() {
                    @Override
                    public void onClick(String input) {

                    }
                });
                break;
            case "DialogKeyValueInput.java":
                androidDialog.showDialogKeyValueInput("内容", "左边", "右边", new DialogKeyValueInput.OnDialogKeyValueInputClickListener() {
                    @Override
                    public void onClick(String key, String value) {

                    }
                }, new DialogKeyValueInput.OnDialogKeyValueInputClickListener() {
                    @Override
                    public void onClick(String key, String value) {

                    }
                });
                break;
            case "DialogKeyValueTable.java":
                ArrayMap<String, String> arrayMap = new ArrayMap<>();
                arrayMap.put("key1", "value1");
                arrayMap.put("key1", "value1");
                arrayMap.put("key1", "value1");
                arrayMap.put("key1", "value1");
                androidDialog.showKeyValueTable(arrayMap);
                break;
            case "DialogLoveHint.java":
                androidDialog.showLoveHint(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                }, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                }, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                }, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                });
                break;
            case "DialogNewVersionHint.java":
                androidDialog.showDialogNewVersionHint("版本号", "更新内容", new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                }, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                });
                break;
            case "DialogPandu.java":
                androidDialog.showDialogPandu(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                }, new DialogPandu.OnPanduSaveClickListener() {
                    @Override
                    public void onPanduSaveClick(List<String> items) {

                    }
                });
                break;
            case "DialogRealNameAuthAndTaxDeclaration.java":
                androidDialog.showRealNameTaxDeclaration(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                }, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                }, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                });
                break;
            case "DialogStandardOneButton.java":
                androidDialog.showDialogOneButton("标题", "内容", "按钮", new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                });
                break;
            case "DialogStandardTwoButton.java":
                androidDialog.showTwoButton("内容", "按钮", "按钮", new DialogStandardTwoButton.OnClickListener() {
                    @Override
                    public void onClick(AlertDialog alertDialog) {
                        alertDialog.dismiss();
                    }
                }, new DialogStandardTwoButton.OnClickListener() {
                    @Override
                    public void onClick(AlertDialog alertDialog) {
                        alertDialog.dismiss();
                    }
                });
                break;
            case "DialogTaskCompleteState.java":
                androidDialog.showDialogTaskCompleteState(100, 20, 80);
                break;
            case "DialogTextItems.java":
                androidDialog.showItems(Arrays.asList("1", "2", "3", "4"), "取消", new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {

                    }
                }, new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                    }
                });
                break;
            case "DialogWaitting.java":
                androidDialog.show();
                recyclerView.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        androidDialog.dismiss();
                    }
                }, 1000 * 5);
                break;
            case "DialogWarn.java":
                androidDialog.warn("警告内容");
                break;
            case "DialogYunChaxun.java":
                androidDialog.showDialogYunChaxun(new DialogYunChaxun.OnOkClickListener() {
                    @Override
                    public void onYunChaxunOkClickListener(List<Integer> types) {

                    }
                });
                break;
        }
    }
}